Skip to content

ref(eap-outcomes): use sentry-options to change which timestamp to use#7838

Merged
kenzoengineer merged 14 commits intomasterfrom
kjiang/use_item_timestamp_option
Mar 31, 2026
Merged

ref(eap-outcomes): use sentry-options to change which timestamp to use#7838
kenzoengineer merged 14 commits intomasterfrom
kjiang/use_item_timestamp_option

Conversation

@kenzoengineer
Copy link
Copy Markdown
Member

This is a duplicate of #7834, using sentry-options instead of the old config method.

#7836 should be merged first to ensure all the scaffolding works in production.

Because this is a duplicate, the logic, usage, and tests all mirror #7834. The only thing I've added is we use sentry-options instead.

@kenzoengineer kenzoengineer requested a review from a team as a code owner March 24, 2026 21:24
@MeredithAnya MeredithAnya force-pushed the kjiang/setup-sentry-options branch from 6c99601 to 77cf17e Compare March 25, 2026 18:16
Base automatically changed from kjiang/setup-sentry-options to master March 25, 2026 21:18
@kenzoengineer kenzoengineer requested a review from onewland March 26, 2026 19:10
@@ -1,3 +1,6 @@
pub(crate) const SNUBA_SCHEMA: &str =
include_str!("../../sentry-options/schemas/snuba/schema.json");
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the schemas are now baked in during compile time.

this means during runtime, init_with_schemas should never fail when crate::SNUBA_SCHEMA is passed in (assuming the schema is not malformed, but this is caught in tests and our CI validation)

our only vulnerabilities now are options() and get()

@@ -129,6 +129,13 @@ impl<TNext: ProcessingStrategy<AggregatedOutcomesBatch>> ProcessingStrategy<Kafk
for OutcomesAggregator<TNext>
{
fn poll(&mut self) -> Result<Option<CommitRequest>, StrategyError> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kenzoengineer so poll can be called like thousands of time a second i don't think we need to be checked every poll, I think we could add like a last_options_check time or something and check and refresh the value like every 5 seconds or 10 seconds?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for posterity: this has been benchmarked and the normal options().get() call takes ~150ns, while a cached call with a 5 second TTL takes ~40ns

while theres a dramatic decrease, the numbers are still in the nanoseconds. We can keep it the naive way for now and in a future PR we can make this optimization if necessary

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

.ok()
.and_then(|o| o.get("consumer.use_item_timestamp").ok())
.and_then(|v| v.as_bool())
.unwrap_or(false);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Option read on every poll causes unnecessary I/O

Medium Severity

options("snuba").get("consumer.use_item_timestamp") is called on every poll() invocation. Since poll() can be called thousands of times per second, this causes excessive reads from the sentry-options backend (filesystem/ConfigMap). The sentry-options library's own quickstart example demonstrates reading values in a loop with a 3-second sleep, suggesting per-call reads are not meant for hot paths. A time-based cache (e.g., refreshing every 5–10 seconds) would maintain dynamic reloadability while avoiding the overhead, as the PR reviewer also suggested.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorrect. we only check memory.

@kenzoengineer kenzoengineer merged commit 5b63073 into master Mar 31, 2026
46 of 47 checks passed
@kenzoengineer kenzoengineer deleted the kjiang/use_item_timestamp_option branch March 31, 2026 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants